package a51qindian.com.comprehensive.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import a51qindian.com.comprehensive.R;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Author: Li
 * Date: 2017/9/13 0013
 * Description: 任务：已完成
 */

public class TaskCompletedAdapter extends RecyclerView.Adapter<TaskCompletedAdapter.TaskCompletedHolder> {


    private LayoutInflater mInflater;
    public TaskCompletedAdapter(Context context){
        mInflater=LayoutInflater.from(context);
    }

    private OnCompletedOpListener mCompletedOpListener;
    @Override
    public TaskCompletedHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view=mInflater.inflate(R.layout.item_task_completed,parent,false);
        TaskCompletedHolder holder=new TaskCompletedHolder(view);
        if (mCompletedOpListener != null) {
            holder.mTxtCall.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mCompletedOpListener.onCall("18852996181");
                }
            });
        }
        return holder;
    }

    @Override
    public void onBindViewHolder(TaskCompletedHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return 10;
    }

    public void setCompletedOpListener(OnCompletedOpListener completedOpListener) {
        mCompletedOpListener = completedOpListener;
    }

    static class TaskCompletedHolder extends RecyclerView.ViewHolder{

        @BindView(R.id.txt_call)
        TextView mTxtCall;
        public TaskCompletedHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }

    public interface OnCompletedOpListener{
        void onCall(String phone);
    }

}
